﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StyleMVVM.DependencyInjection.Impl;

namespace StyleMVVM.DependencyInjection
{
	/// <summary>
	/// Exports marked with this attribute will be used like a singleton. Once instantiated the instance will
	/// be held and used to satisfy imports for the lifetime of the container.
	/// </summary>
	[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
	public class SingletonAttribute : Attribute, ILifeCycleContainerProviderAttribute
	{
		/// <summary>
		/// Provide a new lifecycle container for the export
		/// </summary>
		/// <returns></returns>
		public ILifeCycleContainer ProvideContainer()
		{
			return new PermanentlySharedLifeCycleContainer();
		}
	}
}
